var t = getApp(), a = require("../../api.js");

Page({
    data: {
        navindex: 0,
        orderstate: [ {
            txt: "全部"
        }, {
            txt: "一级分销"
        }, {
            txt: "二级分销"
        }, {
            txt: "三级分销"
        } ],
        is_pay: 0,
        orderList: [],
        page: 1,
        pageSize: 10,
        hasMoreData: !0,
        total: 0,
        According: !1
    },
    onLoad: function(t) {},
    click: function(t) {
        wx.showLoading();
        var a = t.currentTarget.dataset.id;
        console.log(a), this.setData({
            navindex: a,
            is_pay: a,
            page: 1,
            orderList: []
        }), this.getList();
    },
    getList: function() {
        var e = this;
        t.request({
            url: a.distribution.order_list,
            method: "post",
            data: {
                level: e.data.is_pay,
                page: e.data.page
            },
            success: function(t) {
                var a = e.data.orderList;
                if (1 == t.code) {
                    wx.hideLoading(), 1 == e.data.page && (a = []);
                    var o = t.data.data;
                    0 == o.length ? e.setData({
                        orderList: e.data.orderList,
                        hasMoreData: !1,
                        According: !0
                    }) : o.length < e.data.pageSize ? e.setData({
                        orderList: a.concat(o),
                        hasMoreData: !1,
                        According: !1
                    }) : e.setData({
                        orderList: a.concat(o),
                        page: e.data.page + 1,
                        hasMoreData: !0,
                        According: !1
                    });
                } else wx.showToast({
                    title: "暂无数据",
                    duration: 1e3
                });
            }
        });
    },
    onReady: function() {},
    onShow: function() {
        wx.showLoading(), this.getList();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.data.page = 1, console.log(this.data.page), this.getList();
    },
    onReachBottom: function() {
        console.log(this.data.hasMoreData), this.data.hasMoreData ? this.getList() : wx.showToast({
            title: "没有更多数据",
            duration: 1e3,
            icon: "none"
        });
    },
    onShareAppMessage: function() {}
});